/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kallsonys.object;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author allan
 */
@Entity
@Cacheable(false)
@Table(name = "CAMPAIGNS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Campaigns.findAll", query = "SELECT c FROM Campaigns c"),
    @NamedQuery(name = "Campaigns.findByCampaignid", query = "SELECT c FROM Campaigns c WHERE c.campaignid = :campaignid"),
    @NamedQuery(name = "Campaigns.findByCampaigndescription", query = "SELECT c FROM Campaigns c WHERE c.campaigndescription = :campaigndescription"),
    @NamedQuery(name = "Campaigns.findByCampaigndate", query = "SELECT c FROM Campaigns c WHERE c.campaigndate = :campaigndate")})
public class Campaigns implements Serializable {
    @Column(name = "CAMPAIGNDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date campaigndate;
    @Lob
    @Column(name = "CAMPAIGNIMAGE")
    private byte[] campaignimage;
    @Size(max = 4000)
    @Column(name = "CAMPAIGNIMAGEURL")
    private String campaignimageurl;
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @GeneratedValue(generator="CampaignsSeq")
    @SequenceGenerator(name="CampaignsSeq",sequenceName="SEQ_CAMPAIGNS",initialValue=1, allocationSize=1)
    @Column(name = "CAMPAIGNID")
    private BigDecimal campaignid;
    @Size(max = 500)
    @Column(name = "CAMPAIGNDESCRIPTION")
    private String campaigndescription;
    @JoinColumn(name = "PRODUCTID", referencedColumnName = "PRODUCTID")
    @ManyToOne
    private Product productid;

    public Campaigns() {
    }

    public Campaigns(BigDecimal campaignid) {
        this.campaignid = campaignid;
    }

    public BigDecimal getCampaignid() {
        return campaignid;
    }

    public void setCampaignid(BigDecimal campaignid) {
        this.campaignid = campaignid;
    }

    public String getCampaigndescription() {
        return campaigndescription;
    }

    public void setCampaigndescription(String campaigndescription) {
        this.campaigndescription = campaigndescription;
    }

    public Product getProductid() {
        return productid;
    }

    public void setProductid(Product productid) {
        this.productid = productid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (campaignid != null ? campaignid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Campaigns)) {
            return false;
        }
        Campaigns other = (Campaigns) object;
        if ((this.campaignid == null && other.campaignid != null) || (this.campaignid != null && !this.campaignid.equals(other.campaignid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.kallsonys.object.Campaigns[ campaignid=" + campaignid + " ]";
    }

    public Date getCampaigndate() {
        return campaigndate;
    }

    public void setCampaigndate(Date campaigndate) {
        this.campaigndate = campaigndate;
    }

    public byte[] getCampaignimage() {
        return campaignimage;
    }

    public void setCampaignimage(byte[] campaignimage) {
        this.campaignimage = campaignimage;
    }

    public String getCampaignimageurl() {
        return campaignimageurl;
    }

    public void setCampaignimageurl(String campaignimageurl) {
        this.campaignimageurl = campaignimageurl;
    }
    
}
